import '../../utils/request.dart';
import '../model/result_model.dart';
import '../model/school_daily_schedule_model.dart';

///学校作息接口
class SchoolDailyScheduleApi {
  SchoolDailyScheduleApi._();

  static final _singleton = SchoolDailyScheduleApi._();

  factory SchoolDailyScheduleApi() => _singleton;

  ///查询
  Future<SchoolDailyScheduleQueryRes> query(
    final SchoolDailyScheduleQueryReq req,
  ) =>
      request
          .getHandler(
            path: '/school/${req.schoolId}/daily-schedule',
            params: req.toMap(),
          )
          .then((res) => SchoolDailyScheduleQueryRes.fromModel(res));

  ///加载
  Future<SchoolDailyScheduleInfoRes> info(final String id) => request
      .getHandler(path: '/school/daily-schedule/$id')
      .then((res) => SchoolDailyScheduleInfoRes.fromModel(res));

  ///新增
  Future<BaseModelRes> add(final SchoolDailyScheduleAddReq req) =>
      request.postHandler(
        path: '/school/${req.schoolId}/daily-schedule',
        data: req.toMap(),
      );

  ///修改
  Future<BaseModelRes> modify(final SchoolDailyScheduleModifyReq req) =>
      request.putHandler(
        path: '/school/daily-schedule/${req.id}',
        data: req.toMap(),
      );

  ///删除
  Future<BaseModelRes> delete(final String id) =>
      request.deleteHandler(path: '/school/daily-schedule/$id');
}

///学校作息接口单例
final schoolDailyScheduleApi = SchoolDailyScheduleApi();
